]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
appDisplay: Cache app ids in FolderView
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Thu, 13 Aug 2020 23:20:52 +0000 (20:20 -0300)
committerFlorian Müllner <florian.muellner@gmail.com>
Thu, 13 Aug 2020 23:28:51 +0000 (23:28 +0000)
Instead of reading a GSettings and building the app ids list
every single time FolderView needs to check for something,
cache it before redisplay and reuse this cached list everywhere.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1409

js/ui/appDisplay.js

index 1c25dfe39b35ffb3de55d089163195d0a102d48d..c1fb1cb201c4c863326b8b5b195b5747d6cce8d0 100644 (file)
@@ -1604,6 +1604,7 @@ class FolderView extends BaseAppView {
         action.connect('pan', this._onPan.bind(this));
         this._scrollView.add_action(action);
 
+        this._appIds = [];
         this._redisplay();
     }
 
@@ -1649,8 +1650,7 @@ class FolderView extends BaseAppView {
     }
 
     _getItemPosition(item) {
-        const appIds = this._getFolderApps();
-        const appIndex = appIds.indexOf(item.id);
+        const appIndex = this._appIds.indexOf(item.id);
 
         if (appIndex === -1)
             return [-1, -1];
@@ -1660,10 +1660,8 @@ class FolderView extends BaseAppView {
     }
 
     _compareItems(a, b) {
-        const appIds = this._getFolderApps();
-
-        const aPosition = appIds.indexOf(a.id);
-        const bPosition = appIds.indexOf(b.id);
+        const aPosition = this._appIds.indexOf(a.id);
+        const bPosition = this._appIds.indexOf(b.id);
 
         if (aPosition === -1 && bPosition === -1)
             return a.name.localeCompare(b.name);
@@ -1720,9 +1718,8 @@ class FolderView extends BaseAppView {
     _loadApps() {
         let apps = [];
         let appSys = Shell.AppSystem.get_default();
-        const appIds = this._getFolderApps();
 
-        appIds.forEach(appId => {
+        this._appIds.forEach(appId => {
             const app = appSys.lookup_app(appId);
 
             let icon = this._items.get(appId);
@@ -1735,6 +1732,13 @@ class FolderView extends BaseAppView {
         return apps;
     }
 
+    _redisplay() {
+        // Keep the app ids list cached
+        this._appIds = this._getFolderApps();
+
+        super._redisplay();
+    }
+
     acceptDrop(source) {
         if (!super.acceptDrop(source))
             return false;